import { json, isEmpty } from '../index'
/**
* 将对象转成url 字符串
* @param { object } origin 参数对象
* @param { string } placeholder 开头占位符  ? | &
* @return { string } url参数
*/
export function objectToUrl(origin={}, placeholder=''){
	if(isEmpty(origin)){ return '' }
	let url = ''
	Object.entries(origin).forEach(([key,value], index)=>{
		(typeof value === 'object') && ( value = json(value) )
		url += `${index===0?'':'&'}${key}=${value}`
	})
	return placeholder+url
}